<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户中心</title>
    <link rel="stylesheet" type="text/css" href="__STATIC__/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/bootstrap/css/bootstrap.css">
    <style>
        *{
            border: 0;
            outline: 0;
            vertical-align: baseline;
            padding: 0px;
            margin: 0px;
        }
        body{
            font: 95% "Helvetica Neue", Helvetica, sans-serif;
            position: relative;
            background-color: #E5D9D9;
            color: #444;
        }
        #content{
            padding-top: 10px;
            margin: 51px auto;
        }
        .section{
            position: relative;
            margin: 20px;
            padding: 10px;
            background-color: #ffffff;
            overflow:hidden;
            border-radius: 10px;
        }
        .picture{
            float: left;
            display:block;
            margin-right: 20px;;
        }
        .icon{
             float: right;
            display: inline;
            text-decoration: inherit;
        }
        .icon button{

        }
        .caret{
            text-align: center;
        }
        img{
            height: 40px;
        }
        .middle{
            float: left;
            line-height: 20px;
            display: inline;
        }
        .name{
               font-weight: bold;
            color: #6293ff;
            font-size:25px;
        }
        
        .hid{
              clear: both;
              display: none;
               margin-top: 10px;
        }
      .footer{
        text-align: center;
    }
    . footer p{
        color:#3F3838

    }
    </style>
</head>
<body>
<include file="Public/nav"/>
<input type="hidden" value="{$servername}" id="servername">
<div id="content">
    <volist name="FoundRecord1" id="record">
        <div class="section" >
          <div class="picture">
    <img src="__PUBLIC__{$record.pic1}" onerror="imgError(this);">
</div>

            <div class="middle"> <p class="name">{$record.name}</p><p>{$record.post_time}</p></div>
            <div class="icon">
           <div class="btn-group">
   <button type="button" id="load" class="btn btn-primary"  onclick='loading(this,"{$record.id}")' >
      <span class="caret"></span>
      <span class="sr-only">切换下拉菜单</span>
   </button>
   </div>
</div>
   <div class="hid" id="hid{$record.id}" touchend="hide('{$record.id}')">
        <p>
    <strong><span id="span{$record.id}" >{$record.lost_or_pick}</span>时间:</strong>{$record.lost_time}
            </p>
<p>
    <strong>地点:</strong>{$record.place}
</p>
<p>
    <strong>详细描述:</strong>{$record.description}
    </p>
<p ><strong>悬赏:</strong>{$record.adward}</p>
 <p>
    <strong>补充悬赏:</strong>{$record.addition}
</p>
<p>
    <strong>状态:</strong>{$record.status}
</p>
    <p><button class="btn btn-success" onclick="ajax('{$record.id}')">认领完成</button></p>
   </div>
</div>
</volist>
</div>
 <div class="footer">
         <p>红满堂工作室版权所有 盗版必究</p>
      <p>联系工作室:995746872@qq.com(bug反馈)</p>
    </div>
</body>
<script type="text/javascript">
      var Public="__PUBLIC__";

 //图片加载错误处理
  function imgError(image){
    // 替换为默认图片
    console.log(image)
    image.setAttribute("src", Public+'/Img/noPicture.jpg');
    image.onerror=null;
}
function loading(object,id){
    if(object.className== "btn btn-primary")
    {
        object.className='btn btn-primary dropup';
    var lost_or_pick;
    document.getElementById("hid"+id).style.display='block';
     lost_or_pick=document.getElementById("span"+id).innerHTML;
     
    if (lost_or_pick==0) {
        document.getElementById("span"+id).innerHTML='丢失';
    }
    else
        if (lost_or_pick==1) {
             document.getElementById("span"+id).innerHTML='捡到';
        }
    }
    else  
    {
     document.getElementById("hid"+id).style.display='none';
    object.setAttribute("class", "btn btn-primary"); 
}

}

 //认领完成的判断
    function ajax(thing_id) {
        if (confirm('您确认已经认领完成了吗') == true) {
            var request = new XMLHttpRequest();
            request.open('POST', url + '/Home/User/ajax', true);
            request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            request.send('thing_id='+thing_id);
            request.onreadystatechange = function () {
                if (request.readyState == 4 && request.status == 200) {
                    alert('认领完成');
                    window.location.href=url+'/Home/User/index';
                }
            }
        }
    }
    //没有图片时增加默认图片
      var servername=document.getElementById("servername").value;
      var img=document.getElementsByTagName('img');
      for(var i=0;i<img.length;i++)
      {
         if(img[i].src=='http://'+servername+Public+'/')
         img[i].src=Public+'/Img/noPicture.jpg';
      }  
        var url="__APP__";

</script>
<script type="text/javascript" src="__STATIC__/login.js"></script>
<script src="__STATIC__/jquery/jquery.min.js"></script>
<script src="__STATIC__/bootstrap/js/bootstrap.min.js"></script>
</html>